#pragma once

#include "ScriptCompiler/ASTBuilder/ASTBuilder.h"
#include "ScriptCompiler/AST/SentenceNode.h"

class CSentenceBuilder : public IASTBuilder
{
public:
    //if EndTokenIndex is set, the builder will stop at the token before EndTokenIndex
    //otherwise, the builder will stop at the first token after ';'
    CSentenceBuilder(std::shared_ptr<CScriptFileContext> InContext,
        TOptional<int64_t> InEndTokenIndex = TOptional<int64_t>()
    );

    //will consume the ';' at the end of the sentence
    virtual bool ReadCurentToken() override;

    std::shared_ptr<CSentenceNode> Result;
protected:
    std::shared_ptr<CScriptFileContext> Context;

    TOptional<int64_t> EndTokenIndex;
};